using System.Collections;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

public class NewBootUp_NewScreen : MonoBehaviour
{
	[Header("-= References =-")]
	[Header("Shared")]
	[SerializeField]
	private Animator CameraAnimator;

	[SerializeField]
	private Animator HypoasterArmsAnimator;

	[SerializeField]
	private NewBootUo_Manager BootUpManager;

	[SerializeField]
	private Material ConfettiUIMat;

	[Space(5f)]
	[Header("Welcome Screen")]
	[SerializeField]
	private GameObject Screen_Welcome;

	[SerializeField]
	private TextMeshProUGUI[] Screen_Welcome_Texts;

	[SerializeField]
	private Image Screen_Welcome_FragmentationNetworkLogo;

	[Space(5f)]
	[Header("Name Screen")]
	[SerializeField]
	private GameObject Screen_Name;

	[SerializeField]
	private TextMeshProUGUI[] Screen_Name_Texts;

	[SerializeField]
	private GameObject Screen_Name_InputField;

	[Space(5f)]
	[Header("Exposition Screen")]
	[SerializeField]
	private GameObject Screen_Exposition;

	[SerializeField]
	private TextMeshProUGUI[] Screen_Exposition_Texts;

	[SerializeField]
	private RawImage Screen_Exposition_Image;

	[SerializeField]
	private Texture[] Screen_Exposition_Textures;

	[Space(5f)]
	[Header("Webcam Screen")]
	[SerializeField]
	private GameObject Screen_Webcam;

	[SerializeField]
	private TextMeshProUGUI[] Screen_Webcam_Texts;

	[SerializeField]
	private Animator Screen_Webcam_Result;

	[SerializeField]
	private Animator Screen_Webcam_WebcamAnimator;

	[SerializeField]
	private Animator Screen_Webcam_WebcamFlashUIAnimator;

	[Space(5f)]
	[Header("SetupVessel Screen")]
	[SerializeField]
	private GameObject Screen_SetupVessel;

	[SerializeField]
	private TextMeshProUGUI[] Screen_SetupVessel_Texts;

	[SerializeField]
	private GameObject Screen_SetupVessel_VesselMaker;

	[SerializeField]
	private GameObject Screen_SetupVessel_Name;

	[SerializeField]
	private Sprite Screen_SetupVessel_Sprite_ArrowDeselected;

	[SerializeField]
	private Sprite Screen_SetupVessel_Sprite_ArrowSelected;

	[Space(2.5f)]
	[SerializeField]
	private Image VesselMaker_Head;

	[SerializeField]
	private Image VesselMaker_Body;

	[SerializeField]
	private Image VesselMaker_Legs;

	[Space(2.5f)]
	[SerializeField]
	private Sprite[] Sprites_VesselHeads;

	[SerializeField]
	private Sprite[] Sprites_VesselBody;

	[SerializeField]
	private Sprite[] Sprites_VesselLegs;

	[Space(2.5f)]
	[SerializeField]
	private int VesselIndex_Head;

	[SerializeField]
	private int VesselIndex_Body;

	[SerializeField]
	private int VesselIndex_Legs;

	[Space(2.5f)]
	[SerializeField]
	private Image VesselMaker_Head_ArrowLeft;

	[SerializeField]
	private Image VesselMaker_Head_ArrowRight;

	[SerializeField]
	private Image VesselMaker_Body_ArrowLeft;

	[SerializeField]
	private Image VesselMaker_Body_ArrowRight;

	[SerializeField]
	private Image VesselMaker_Legs_ArrowLeft;

	[SerializeField]
	private Image VesselMaker_Legs_ArrowRight;

	[Space(5f)]
	[Header("Durability Intro Screen")]
	[SerializeField]
	private GameObject Screen_DurabilityIntro;

	[SerializeField]
	private TextMeshProUGUI[] Screen_DurabilityIntro_Texts;

	[Space(5f)]
	[Header("Durability Maze Screen")]
	[SerializeField]
	private GameObject Screen_DurabilityMaze;

	[SerializeField]
	private TextMeshProUGUI[] Screen_DurabilityMaze_Texts;

	[SerializeField]
	private Transform Screen_DurabilityMaze_Soul;

	[SerializeField]
	private Transform Screen_DurabilityMaze_Finish;

	[Space(5f)]
	[Header("Durability Math Screen")]
	[SerializeField]
	private GameObject Screen_DurabilityMath;

	[SerializeField]
	private Transform Screen_DurabilityMath_Soul;

	[SerializeField]
	private TextMeshProUGUI Screen_DurabilityMath_Question;

	[SerializeField]
	private TextMeshProUGUI[] Screen_DurabilityMath_Answers;

	[Space(5f)]
	[Header("_______________")]
	[Space(5f)]
	[Header("Audio")]
	[SerializeField]
	private AudioClip[] SFX_TypingSound;

	[SerializeField]
	private AudioClip[] SFX_HypoasterMovement_Sharp;

	[SerializeField]
	private AudioClip[] SFX_HypoasterMovement_Soft;

	[SerializeField]
	private AudioClip SFX_OpenScreen;

	[SerializeField]
	private AudioClip SFX_Notification;

	[SerializeField]
	private AudioClip SFX_Confirm;

	[SerializeField]
	private AudioClip SFX_Deny;

	[SerializeField]
	private AudioClip SFX_Move;

	[SerializeField]
	private AudioClip SFX_WebcamFlash;

	[SerializeField]
	private AudioClip SFX_Success;

	[Space(5f)]
	[Header("_______________")]
	[Space(5f)]
	[Header("-= Chatbox =-")]
	[SerializeField]
	private AudioClip TypeSound;

	public List<string> StoredAdditiveValues = new List<string>();

	private bool hasFinishedVesselCreation;

	private void Update()
	{
		if (DRHDebugManager.instance.DebugModeEnabled && Input.GetKeyDown(KeyCode.L))
		{
			StopAllCoroutines();
			Screen_Welcome.SetActive(value: false);
			BootUpManager.StartCoroutine(BootUpManager.DisclaimerCutscene());
		}
	}

	private void Start()
	{
		ConfettiUIMat.SetFloat("_Progress", 0f);
	}

	public IEnumerator Cutscene()
	{
		yield return new WaitForSeconds(0.2f);
		Screen_Welcome.SetActive(value: true);
		CutsceneUtils.PlaySound(SFX_OpenScreen, CutsceneUtils.DRH_MixerChannels.Effect, 0.7f);
		yield return new WaitForSeconds(0.75f);
		TypeText(Screen_Welcome_Texts[0], "WELCOME NEW USER", 1f, PlayTypeSound: true);
		yield return new WaitForSeconds(1.65f);
		TypeText(Screen_Welcome_Texts[1], "You've been personally invited to join the", 1f, PlayTypeSound: true);
		yield return new WaitForSeconds(2.5f);
		Screen_Welcome_FragmentationNetworkLogo.enabled = true;
		CutsceneUtils.PlaySound(SFX_Notification, CutsceneUtils.DRH_MixerChannels.Effect, 0.7f);
		yield return new WaitForSeconds(2.5f);
		HypoasterArmsAnimator.Play("NewBootUp_HypoasterArms_PrepareTyping");
		TypeText(Screen_Welcome_Texts[1], $"Press {PlayerInput.Instance.Key_Confirm} to Confirm. <br>Press {PlayerInput.Instance.Key_Cancel} to Deny.", 1f, PlayTypeSound: true);
		yield return new WaitForSeconds(1.5f);
		bool CanProgress = false;
		while (!CanProgress)
		{
			if (Input.GetKeyDown(PlayerInput.Instance.Key_Confirm))
			{
				CanProgress = true;
				CutsceneUtils.PlaySound(SFX_Confirm, CutsceneUtils.DRH_MixerChannels.Effect, 0.4f);
				HypoasterArmsAnimator.Play($"NewBootUp_HypoasterArms_Type{Random.Range(1, 5)}", -1, 0f);
				CutsceneUtils.PlaySound(SFX_TypingSound[Random.Range(0, SFX_TypingSound.Length)], CutsceneUtils.DRH_MixerChannels.Effect, Random.Range(0.65f, 0.85f), Random.Range(0.9f, 1.1f));
			}
			if (Input.GetKeyDown(PlayerInput.Instance.Key_Cancel) && !CameraAnimator.GetCurrentAnimatorStateInfo(0).IsName("NewBootUp_Camera_ShakeHead"))
			{
				CameraAnimator.SetTrigger("ShakeHead");
				CutsceneUtils.PlaySound(SFX_HypoasterMovement_Soft[Random.Range(0, SFX_HypoasterMovement_Soft.Length)], CutsceneUtils.DRH_MixerChannels.Effect, 0.85f);
				yield return null;
				CameraAnimator.ResetTrigger("ShakeHead");
			}
			yield return null;
		}
		TypeText(Screen_Welcome_Texts[0], " ", 5f, PlayTypeSound: false);
		TypeText(Screen_Welcome_Texts[1], " ", 5f, PlayTypeSound: false);
		yield return new WaitForSeconds(1f);
		HypoasterArmsAnimator.Play("NewBootUp_HypoasterArms_StopTyping");
		Screen_Welcome.SetActive(value: false);
		yield return new WaitForSeconds(1.5f);
		Screen_Name.SetActive(value: true);
		CutsceneUtils.PlaySound(SFX_OpenScreen, CutsceneUtils.DRH_MixerChannels.Effect, 0.7f);
		yield return new WaitForSeconds(0.75f);
		TypeText(Screen_Name_Texts[0], "AMAZING!", 1f, PlayTypeSound: true);
		yield return new WaitForSeconds(1.25f);
		TypeText(Screen_Name_Texts[1], "Firstly, please provide us with a name for yourself.", 1f, PlayTypeSound: true);
		HypoasterArmsAnimator.Play("NewBootUp_HypoasterArms_PrepareTyping");
		yield return new WaitForSeconds(2.25f);
		Screen_Name_InputField.SetActive(value: true);
		Screen_Name_Texts[3].maxVisibleCharacters = 0;
		Screen_Name_Texts[3].text = "HYPOASTER";
		CanProgress = false;
		while (!CanProgress)
		{
			if (Screen_Name_Texts[3].maxVisibleCharacters <= 8)
			{
				if (Input.anyKeyDown && !Input.GetMouseButtonDown(0) && !Input.GetMouseButtonDown(1) && !Input.GetMouseButtonDown(2) && !Input.GetMouseButtonDown(3))
				{
					Screen_Name_Texts[2].enabled = false;
					HypoasterArmsAnimator.Play($"NewBootUp_HypoasterArms_Type{Random.Range(1, 5)}", -1, 0f);
					CutsceneUtils.PlaySound(SFX_TypingSound[Random.Range(0, SFX_TypingSound.Length)], CutsceneUtils.DRH_MixerChannels.Effect, Random.Range(0.65f, 0.85f), Random.Range(0.9f, 1.1f));
					Screen_Name_Texts[3].maxVisibleCharacters++;
				}
			}
			else if (Input.anyKeyDown && !Input.GetMouseButtonDown(0) && !Input.GetMouseButtonDown(1) && !Input.GetMouseButtonDown(2) && !Input.GetMouseButtonDown(3))
			{
				HypoasterArmsAnimator.Play($"NewBootUp_HypoasterArms_Type{Random.Range(1, 5)}", -1, 0f);
				CutsceneUtils.PlaySound(SFX_TypingSound[Random.Range(0, SFX_TypingSound.Length)], CutsceneUtils.DRH_MixerChannels.Effect, Random.Range(0.65f, 0.85f), Random.Range(0.9f, 1.1f));
				CanProgress = true;
			}
			yield return null;
		}
		CutsceneUtils.PlaySound(SFX_Confirm, CutsceneUtils.DRH_MixerChannels.Effect, 0.4f);
		yield return new WaitForSeconds(1.25f);
		HypoasterArmsAnimator.Play("NewBootUp_HypoasterArms_StopTyping");
		Screen_Name.SetActive(value: false);
		yield return new WaitForSeconds(1.25f);
		Screen_Exposition.SetActive(value: true);
		CutsceneUtils.PlaySound(SFX_OpenScreen, CutsceneUtils.DRH_MixerChannels.Effect, 0.7f);
		yield return new WaitForSeconds(0.75f);
		TypeText(Screen_Exposition_Texts[0], "GREETINGS!", 1f, PlayTypeSound: true);
		yield return new WaitForSeconds(1.25f);
		TypeText(Screen_Exposition_Texts[1], "\"HYPOASTER\"", 3f, PlayTypeSound: true);
		yield return new WaitForSeconds(2.5f);
		TypeText(Screen_Exposition_Texts[2], "H", 1f, PlayTypeSound: false);
		TypeText(Screen_Exposition_Texts[1], "Currently, you are suffering from three feelings.", 0.5f, PlayTypeSound: true);
		yield return new WaitForSeconds(4f);
		TypeText(Screen_Exposition_Texts[2], "K", 1f, PlayTypeSound: false);
		TypeText(Screen_Exposition_Texts[1], "Confused, about this entire situation you've awoken in.", 0.5f, PlayTypeSound: true);
		yield return new WaitForSeconds(4.5f);
		TypeText(Screen_Exposition_Texts[2], "L", 1f, PlayTypeSound: false);
		TypeText(Screen_Exposition_Texts[1], "Overwhelmed, with all these new thoughts rushing through your head.", 0.5f, PlayTypeSound: true);
		yield return new WaitForSeconds(5.5f);
		TypeText(Screen_Exposition_Texts[2], "N", 1f, PlayTypeSound: false);
		TypeText(Screen_Exposition_Texts[1], "And worst of all, purposeless.", 0.5f, PlayTypeSound: true);
		yield return new WaitForSeconds(3.5f);
		TypeText(Screen_Exposition_Texts[2], "D", 1f, PlayTypeSound: false);
		TypeText(Screen_Exposition_Texts[1], "We're all stuck in this nothingness, devoid of hope.", 0.5f, PlayTypeSound: true);
		yield return new WaitForSeconds(4.75f);
		TypeText(Screen_Exposition_Texts[2], "C", 1f, PlayTypeSound: false);
		TypeText(Screen_Exposition_Texts[1], "The <color=green>FRAGMENTATION NETWORK</color> aims to solve this conundrum.", 0.5f, PlayTypeSound: true);
		yield return new WaitForSeconds(4.5f);
		TypeText(Screen_Exposition_Texts[2], "4", 1f, PlayTypeSound: false);
		TypeText(Screen_Exposition_Texts[1], "We are a team of researchers, working together with one goal in mind.", 0.5f, PlayTypeSound: true);
		yield return new WaitForSeconds(5.5f);
		TypeText(Screen_Exposition_Texts[2], "(", 1f, PlayTypeSound: false);
		TypeText(Screen_Exposition_Texts[1], "To break free from this hell. ;To reconnect.", 0.5f, PlayTypeSound: true);
		yield return new WaitForSeconds(4.5f);
		TypeText(Screen_Exposition_Texts[2], "I", 1f, PlayTypeSound: false);
		TypeText(Screen_Exposition_Texts[1], "Welcome to the <color=green>FRAGMENTATION NETWORK</color>, \"HYPOASTER\".", 0.5f, PlayTypeSound: true);
		yield return new WaitForSeconds(4.5f);
		TypeText(Screen_Exposition_Texts[2], "J", 1f, PlayTypeSound: false);
		TypeText(Screen_Exposition_Texts[1], "We pray that one day, we can all meet once again.", 0.5f, PlayTypeSound: true);
		yield return new WaitForSeconds(4.75f);
		TypeText(Screen_Exposition_Texts[2], " ", 1f, PlayTypeSound: false);
		TypeText(Screen_Exposition_Texts[1], " ", 0.5f, PlayTypeSound: false);
		TypeText(Screen_Exposition_Texts[0], " ", 0.5f, PlayTypeSound: false);
		yield return new WaitForSeconds(1f);
		Screen_Exposition.SetActive(value: false);
		yield return new WaitForSeconds(1.25f);
		Screen_Webcam.SetActive(value: true);
		CutsceneUtils.PlaySound(SFX_OpenScreen, CutsceneUtils.DRH_MixerChannels.Effect, 0.7f);
		yield return new WaitForSeconds(1f);
		TypeText(Screen_Webcam_Texts[0], "First, we must set up your profile.", 1f, PlayTypeSound: true);
		yield return new WaitForSeconds(4f);
		TypeText(Screen_Webcam_Texts[0], "Please look up and smile at the webcam!", 1f, PlayTypeSound: true);
		yield return new WaitForSeconds(2f);
		Screen_Webcam_Result.Play("NewBootUp_WebcamUI_HypoasterLook");
		yield return new WaitForSeconds(2.5f);
		CameraAnimator.Play("NewBootUp_Camera_Webcam");
		yield return new WaitForSeconds(2.6f);
		HypoasterArmsAnimator.Play("NewBootUp_HypoasterArms_Recoil");
		Screen_Webcam_WebcamAnimator.Play("NewBootUp_Webcam_Flash");
		CutsceneUtils.PlaySound(SFX_WebcamFlash, CutsceneUtils.DRH_MixerChannels.Effect, 0.5f);
		CutsceneUtils.PlaySound(SFX_HypoasterMovement_Soft[Random.Range(0, SFX_HypoasterMovement_Sharp.Length)], CutsceneUtils.DRH_MixerChannels.Effect, 0.5f);
		yield return new WaitForSeconds(1f);
		TypeText(Screen_Webcam_Texts[0], "Stunning!", 1f, PlayTypeSound: false);
		yield return new WaitForSeconds(3f);
		CameraAnimator.Play("NewBootUp_Camera_WebcamAnnoyed");
		HypoasterArmsAnimator.Play("NewBootUp_HypoasterArms_WebcamAnnoyed");
		hasFinishedVesselCreation = false;
		yield return new WaitForSeconds(5f);
		StartCoroutine(VesselCreator());
		while (!hasFinishedVesselCreation)
		{
			yield return null;
		}
		CutsceneUtils.PlaySound(SFX_OpenScreen, CutsceneUtils.DRH_MixerChannels.Effect, 0.7f);
		Screen_DurabilityIntro.SetActive(value: true);
		yield return new WaitForSeconds(0.75f);
		TypeText(Screen_DurabilityIntro_Texts[0], "Fragment Durability Test", 1f, PlayTypeSound: true);
		yield return new WaitForSeconds(1.5f);
		TypeText(Screen_DurabilityIntro_Texts[1], "All new fragments must take the durability test to gauge their efficiency and intelligence.", 1f, PlayTypeSound: true);
		yield return new WaitForSeconds(9f);
		TypeText(Screen_DurabilityIntro_Texts[0], "", 1f, PlayTypeSound: false);
		TypeText(Screen_DurabilityIntro_Texts[1], "", 1f, PlayTypeSound: false);
		yield return new WaitForSeconds(0.25f);
		Screen_DurabilityIntro.SetActive(value: false);
		HypoasterArmsAnimator.Play("NewBootUp_HypoasterArms_PrepareProxyControl");
		yield return new WaitForSeconds(0.75f);
		CutsceneUtils.PlaySound(SFX_OpenScreen, CutsceneUtils.DRH_MixerChannels.Effect, 0.7f);
		Screen_DurabilityMaze.SetActive(value: true);
		TypeText(Screen_DurabilityMaze_Texts[0], $"Navigate the <color=red>PROXY</color> to the finish. ;<color=yellow>{PlayerInput.Instance.Key_Up},{PlayerInput.Instance.Key_Down},{PlayerInput.Instance.Key_Left},{PlayerInput.Instance.Key_Right}</color> to Navigate.;<color=yellow>{PlayerInput.Instance.Key_Sprint}</color> to move Slowly.", 1f, PlayTypeSound: true);
		TypeText(Screen_DurabilityIntro_Texts[0], "Fragment Durability Test", 1f, PlayTypeSound: false);
		while (Vector3.Distance(Screen_DurabilityMaze_Soul.position, Screen_DurabilityMaze_Finish.position) > 0.2f)
		{
			HypoasterArmsAnimator.SetFloat("InputX", Mathf.Lerp(HypoasterArmsAnimator.GetFloat("InputX"), PlayerInput.GetHorizontalInput(), 7.5f * Time.deltaTime));
			HypoasterArmsAnimator.SetFloat("InputY", Mathf.Lerp(HypoasterArmsAnimator.GetFloat("InputY"), PlayerInput.GetVerticalInput(), 7.5f * Time.deltaTime));
			if (Input.GetKeyDown(PlayerInput.Instance.Key_Up) || Input.GetKeyDown(PlayerInput.Instance.Key_Down) || Input.GetKeyDown(PlayerInput.Instance.Key_Left) || Input.GetKeyDown(PlayerInput.Instance.Key_Right))
			{
				HypoasterArmsAnimator.Play("NewBootUp_HypoasterArms_ProxyControl_Tap", 2, 0f);
				CutsceneUtils.PlaySound(SFX_TypingSound[Random.Range(0, SFX_TypingSound.Length)], CutsceneUtils.DRH_MixerChannels.Effect, Random.Range(0.65f, 0.85f), Random.Range(0.9f, 1.1f));
			}
			yield return null;
		}
		Screen_DurabilityMaze_Soul.gameObject.SetActive(value: false);
		Screen_DurabilityMaze_Finish.gameObject.SetActive(value: false);
		CutsceneUtils.PlaySound(SFX_Confirm, CutsceneUtils.DRH_MixerChannels.Effect, 0.7f);
		yield return new WaitForSeconds(1f);
		HypoasterArmsAnimator.Play("NewBootUp_HypoasterArms_StopRightTyping");
		Screen_DurabilityMaze.SetActive(value: false);
		yield return new WaitForSeconds(1f);
		CutsceneUtils.PlaySound(SFX_OpenScreen, CutsceneUtils.DRH_MixerChannels.Effect, 0.7f);
		Screen_DurabilityIntro.SetActive(value: true);
		yield return new WaitForSeconds(0.75f);
		TypeText(Screen_DurabilityIntro_Texts[1], "Next, we shall test your mental capacity.", 1f, PlayTypeSound: true);
		yield return new WaitForSeconds(4f);
		TypeText(Screen_DurabilityIntro_Texts[1], "In the upcoming test, you will be asked to answer mathematical equations.", 1f, PlayTypeSound: true);
		yield return new WaitForSeconds(5f);
		TypeText(Screen_DurabilityIntro_Texts[1], "Use the <color=red>PROXY</color> to select which answer you believe to be correct.", 1f, PlayTypeSound: true);
		yield return new WaitForSeconds(5f);
		HypoasterArmsAnimator.Play("NewBootUp_HypoasterArms_PrepareProxyControl");
		Screen_DurabilityIntro.SetActive(value: false);
		yield return new WaitForSeconds(1f);
		Screen_DurabilityMath_Question.text = "2 + 7";
		Screen_DurabilityMath_Answers[0].text = "8";
		Screen_DurabilityMath_Answers[1].text = "10";
		Screen_DurabilityMath_Answers[2].text = "9";
		CutsceneUtils.PlaySound(SFX_OpenScreen, CutsceneUtils.DRH_MixerChannels.Effect, 0.7f);
		Screen_DurabilityMath.SetActive(value: true);
		TypeText(Screen_DurabilityIntro_Texts[1], "", 1f, PlayTypeSound: false);
		TypeText(Screen_DurabilityIntro_Texts[0], "", 1f, PlayTypeSound: false);
		bool hasAnswered = false;
		while (!hasAnswered)
		{
			yield return null;
			HypoasterArmsAnimator.SetFloat("InputX", Mathf.Lerp(HypoasterArmsAnimator.GetFloat("InputX"), PlayerInput.GetHorizontalInput(), 7.5f * Time.deltaTime));
			HypoasterArmsAnimator.SetFloat("InputY", Mathf.Lerp(HypoasterArmsAnimator.GetFloat("InputY"), PlayerInput.GetVerticalInput(), 7.5f * Time.deltaTime));
			if (Input.GetKeyDown(PlayerInput.Instance.Key_Up) || Input.GetKeyDown(PlayerInput.Instance.Key_Down) || Input.GetKeyDown(PlayerInput.Instance.Key_Left) || Input.GetKeyDown(PlayerInput.Instance.Key_Right))
			{
				HypoasterArmsAnimator.Play("NewBootUp_HypoasterArms_ProxyControl_Tap", 2, 0f);
				CutsceneUtils.PlaySound(SFX_TypingSound[Random.Range(0, SFX_TypingSound.Length)], CutsceneUtils.DRH_MixerChannels.Effect, Random.Range(0.65f, 0.85f), Random.Range(0.9f, 1.1f));
			}
			TextMeshProUGUI[] screen_DurabilityMath_Answers = Screen_DurabilityMath_Answers;
			foreach (TextMeshProUGUI textMeshProUGUI in screen_DurabilityMath_Answers)
			{
				if (Vector3.Distance(Screen_DurabilityMath_Soul.position, textMeshProUGUI.transform.position) < 0.15f)
				{
					hasAnswered = true;
					if (int.Parse(textMeshProUGUI.text) == 9)
					{
						CutsceneUtils.PlaySound(SFX_Confirm, CutsceneUtils.DRH_MixerChannels.Effect, 0.7f);
					}
					else
					{
						CutsceneUtils.PlaySound(SFX_Deny, CutsceneUtils.DRH_MixerChannels.Effect, 0.7f);
					}
				}
			}
		}
		yield return null;
		Screen_DurabilityMath.SetActive(value: false);
		yield return new WaitForSeconds(0.25f);
		CutsceneUtils.PlaySound(SFX_OpenScreen, CutsceneUtils.DRH_MixerChannels.Effect, 0.7f);
		Screen_DurabilityMath.SetActive(value: true);
		Screen_DurabilityMath_Soul.localPosition = new Vector3(0f, -285f, 0f);
		hasAnswered = false;
		Screen_DurabilityMath_Question.text = "6 x 2";
		Screen_DurabilityMath_Answers[0].text = "12";
		Screen_DurabilityMath_Answers[1].text = "8";
		Screen_DurabilityMath_Answers[2].text = "14";
		while (!hasAnswered)
		{
			yield return null;
			HypoasterArmsAnimator.SetFloat("InputX", Mathf.Lerp(HypoasterArmsAnimator.GetFloat("InputX"), PlayerInput.GetHorizontalInput(), 7.5f * Time.deltaTime));
			HypoasterArmsAnimator.SetFloat("InputY", Mathf.Lerp(HypoasterArmsAnimator.GetFloat("InputY"), PlayerInput.GetVerticalInput(), 7.5f * Time.deltaTime));
			if (Input.GetKeyDown(PlayerInput.Instance.Key_Up) || Input.GetKeyDown(PlayerInput.Instance.Key_Down) || Input.GetKeyDown(PlayerInput.Instance.Key_Left) || Input.GetKeyDown(PlayerInput.Instance.Key_Right))
			{
				HypoasterArmsAnimator.Play("NewBootUp_HypoasterArms_ProxyControl_Tap", 2, 0f);
				CutsceneUtils.PlaySound(SFX_TypingSound[Random.Range(0, SFX_TypingSound.Length)], CutsceneUtils.DRH_MixerChannels.Effect, Random.Range(0.65f, 0.85f), Random.Range(0.9f, 1.1f));
			}
			TextMeshProUGUI[] screen_DurabilityMath_Answers = Screen_DurabilityMath_Answers;
			foreach (TextMeshProUGUI textMeshProUGUI2 in screen_DurabilityMath_Answers)
			{
				if (Vector3.Distance(Screen_DurabilityMath_Soul.position, textMeshProUGUI2.transform.position) < 0.15f)
				{
					hasAnswered = true;
					if (int.Parse(textMeshProUGUI2.text) == 12)
					{
						CutsceneUtils.PlaySound(SFX_Confirm, CutsceneUtils.DRH_MixerChannels.Effect, 0.7f);
					}
					else
					{
						CutsceneUtils.PlaySound(SFX_Deny, CutsceneUtils.DRH_MixerChannels.Effect, 0.7f);
					}
				}
			}
		}
		yield return null;
		Screen_DurabilityMath.SetActive(value: false);
		yield return new WaitForSeconds(0.25f);
		CutsceneUtils.PlaySound(SFX_OpenScreen, CutsceneUtils.DRH_MixerChannels.Effect, 0.7f);
		Screen_DurabilityMath.SetActive(value: true);
		Screen_DurabilityMath_Soul.localPosition = new Vector3(0f, -285f, 0f);
		hasAnswered = false;
		Screen_DurabilityMath_Question.text = "75 / 3";
		Screen_DurabilityMath_Answers[0].text = "5";
		Screen_DurabilityMath_Answers[1].text = "15";
		Screen_DurabilityMath_Answers[2].text = "25";
		while (!hasAnswered)
		{
			yield return null;
			HypoasterArmsAnimator.SetFloat("InputX", Mathf.Lerp(HypoasterArmsAnimator.GetFloat("InputX"), PlayerInput.GetHorizontalInput(), 7.5f * Time.deltaTime));
			HypoasterArmsAnimator.SetFloat("InputY", Mathf.Lerp(HypoasterArmsAnimator.GetFloat("InputY"), PlayerInput.GetVerticalInput(), 7.5f * Time.deltaTime));
			if (Input.GetKeyDown(PlayerInput.Instance.Key_Up) || Input.GetKeyDown(PlayerInput.Instance.Key_Down) || Input.GetKeyDown(PlayerInput.Instance.Key_Left) || Input.GetKeyDown(PlayerInput.Instance.Key_Right))
			{
				HypoasterArmsAnimator.Play("NewBootUp_HypoasterArms_ProxyControl_Tap", 2, 0f);
				CutsceneUtils.PlaySound(SFX_TypingSound[Random.Range(0, SFX_TypingSound.Length)], CutsceneUtils.DRH_MixerChannels.Effect, Random.Range(0.65f, 0.85f), Random.Range(0.9f, 1.1f));
			}
			TextMeshProUGUI[] screen_DurabilityMath_Answers = Screen_DurabilityMath_Answers;
			foreach (TextMeshProUGUI textMeshProUGUI3 in screen_DurabilityMath_Answers)
			{
				if (Vector3.Distance(Screen_DurabilityMath_Soul.position, textMeshProUGUI3.transform.position) < 0.15f)
				{
					hasAnswered = true;
					if (int.Parse(textMeshProUGUI3.text) == 25)
					{
						CutsceneUtils.PlaySound(SFX_Confirm, CutsceneUtils.DRH_MixerChannels.Effect, 0.7f);
					}
					else
					{
						CutsceneUtils.PlaySound(SFX_Deny, CutsceneUtils.DRH_MixerChannels.Effect, 0.7f);
					}
				}
			}
		}
		yield return null;
		Screen_DurabilityMath.SetActive(value: false);
		float waittimer = 0f;
		while (waittimer <= 2.5f)
		{
			yield return null;
			waittimer += Time.deltaTime;
			HypoasterArmsAnimator.SetFloat("InputX", Mathf.Lerp(HypoasterArmsAnimator.GetFloat("InputX"), 0f, 5f * Time.deltaTime));
			HypoasterArmsAnimator.SetFloat("InputY", Mathf.Lerp(HypoasterArmsAnimator.GetFloat("InputY"), 0f, 5f * Time.deltaTime));
		}
		CutsceneUtils.PlaySound(SFX_OpenScreen, CutsceneUtils.DRH_MixerChannels.Effect, 0.7f, 0.85f);
		Screen_DurabilityMath.SetActive(value: true);
		Screen_DurabilityMath_Soul.localPosition = new Vector3(0f, -285f, 0f);
		hasAnswered = false;
		Screen_DurabilityMath_Question.text = "null + null";
		Screen_DurabilityMath_Answers[0].text = "null";
		Screen_DurabilityMath_Answers[1].text = "0";
		string[] possibleChars = new string[72]
		{
			"天","地","玄","黄","宇","宙","洪","荒","日","月",
			"盈","昃","辰","宿","列","张","寒","来","暑","往",
			"秋","收","冬","藏","闰","余","成","岁","律","吕",
			"调","阳","云","腾","致","雨","露","结","为","霜",
			"金","生","丽","水","玉","出","昆","冈","剑","号",
			"巨","阙","珠","称","夜","光","果","珍","李","柰",
			"菜","重","芥","姜","海","咸","河","淡","鳞","潜",
			"羽","翔"
		};
		while (!hasAnswered)
		{
			yield return null;
			HypoasterArmsAnimator.SetFloat("InputX", Mathf.Lerp(HypoasterArmsAnimator.GetFloat("InputX"), PlayerInput.GetHorizontalInput(), 7.5f * Time.deltaTime));
			HypoasterArmsAnimator.SetFloat("InputY", Mathf.Lerp(HypoasterArmsAnimator.GetFloat("InputY"), PlayerInput.GetVerticalInput(), 7.5f * Time.deltaTime));
			if (Input.GetKeyDown(PlayerInput.Instance.Key_Up) || Input.GetKeyDown(PlayerInput.Instance.Key_Down) || Input.GetKeyDown(PlayerInput.Instance.Key_Left) || Input.GetKeyDown(PlayerInput.Instance.Key_Right))
			{
				HypoasterArmsAnimator.Play("NewBootUp_HypoasterArms_ProxyControl_Tap", 2, 0f);
				CutsceneUtils.PlaySound(SFX_TypingSound[Random.Range(0, SFX_TypingSound.Length)], CutsceneUtils.DRH_MixerChannels.Effect, Random.Range(0.65f, 0.85f), Random.Range(0.9f, 1.1f));
			}
			Screen_DurabilityMath_Answers[2].text = GetRandomText(Random.Range(1, 3), possibleChars);
			TextMeshProUGUI[] screen_DurabilityMath_Answers = Screen_DurabilityMath_Answers;
			foreach (TextMeshProUGUI textMeshProUGUI4 in screen_DurabilityMath_Answers)
			{
				if (Vector3.Distance(Screen_DurabilityMath_Soul.position, textMeshProUGUI4.transform.position) < 0.15f)
				{
					hasAnswered = true;
					CutsceneUtils.PlaySound(SFX_Deny, CutsceneUtils.DRH_MixerChannels.Effect, 0.7f);
				}
			}
		}
		Screen_DurabilityMath.SetActive(value: false);
		yield return new WaitForSeconds(0.25f);
		HypoasterArmsAnimator.Play("NewBootUp_HypoasterArms_StopRightTyping");
		yield return new WaitForSeconds(1f);
		Screen_DurabilityIntro.SetActive(value: true);
		Screen_DurabilityIntro_Texts[0].maxVisibleCharacters = 100;
		Screen_DurabilityIntro_Texts[0].text = "碎片耐久度测试结果"; // 片段耐久性测试结果
		yield return new WaitForSeconds(1.25f);
		TypeText(Screen_DurabilityIntro_Texts[1], "Congratulations!", 1f, PlayTypeSound: true);
		yield return new WaitForSeconds(3f);
		TypeText(Screen_DurabilityIntro_Texts[1], "With the data gathered, a decision has been made.", 1f, PlayTypeSound: true);
		yield return new WaitForSeconds(4.5f);
		TypeText(Screen_DurabilityIntro_Texts[1], "You have been selected to join the:", 1f, PlayTypeSound: true);
		yield return new WaitForSeconds(2.65f);
		CutsceneUtils.PlaySound(SFX_Success, CutsceneUtils.DRH_MixerChannels.Effect, 0.4f);
		TypeText(Screen_DurabilityIntro_Texts[1], "<color=green>SIMULATION RESEARCH DIVISION</color>;As a Junior Researcher.", 2f, PlayTypeSound: true);
		float confettitimer = 0f;
		while (confettitimer < 10f)
		{
			yield return null;
			confettitimer += Time.deltaTime * 1.25f;
			ConfettiUIMat.SetFloat("_Progress", confettitimer);
		}
		yield return new WaitForSeconds(7f);
		TypeText(Screen_DurabilityIntro_Texts[1], "You and your fellow researchers will be spearheading the investigation into the <color=green>SIMULATION</color>.", 1f, PlayTypeSound: true);
		yield return new WaitForSeconds(7.5f);
		Screen_DurabilityIntro.SetActive(value: false);
		Screen_DurabilityIntro_Texts[0].maxVisibleCharacters = 100;
		Screen_DurabilityIntro_Texts[0].text = "<color=green>模拟</color>程序";
		Screen_DurabilityIntro_Texts[1].text = "";
		yield return new WaitForSeconds(0.5f);
		Screen_DurabilityIntro.SetActive(value: true);
		yield return new WaitForSeconds(0.25f);
		TypeText(Screen_DurabilityIntro_Texts[1], "The <color=green>SIMULATION</color> is a program that you will become VERY acquainted with.", 1f, PlayTypeSound: true);
		yield return new WaitForSeconds(5f);
		TypeText(Screen_DurabilityIntro_Texts[1], "We have written a basic explanation with our current knowledge on the subject.", 1f, PlayTypeSound: true);
		yield return new WaitForSeconds(8f);
		TypeText(Screen_DurabilityIntro_Texts[1], "This has been placed within the SIMULATION_MANUAL.TXT, located in your logs.", 1f, PlayTypeSound: true);
		yield return new WaitForSeconds(6f);
		TypeText(Screen_DurabilityIntro_Texts[1], "Finally, you shall be having a quick meeting with a <color=green>NETWORK ADMIN</color> shortly.", 1f, PlayTypeSound: true);
		yield return new WaitForSeconds(7f);
		TypeText(Screen_DurabilityIntro_Texts[1], "Welcome to the <color=green>FRAGMENTATION NETWORK</color>, DR. HYPOASTER.", 1f, PlayTypeSound: true);
		yield return new WaitForSeconds(5.5f);
		Screen_DurabilityIntro.SetActive(value: false);
		yield return new WaitForSeconds(0.25f);
		BootUpManager.StartCoroutine(BootUpManager.DisclaimerCutscene());
	}

	private string GetRandomText(int length, string[] possibleChars)
	{
		string text = "";
		for (int i = 0; i < length; i++)
		{
			int num = Random.Range(0, possibleChars.Length);
			text += possibleChars[num];
		}
		return text;
	}

	public IEnumerator VesselCreator()
	{
		Screen_Webcam.SetActive(value: false);
		yield return new WaitForSeconds(1.25f);
		Screen_SetupVessel.SetActive(value: true);
		CutsceneUtils.PlaySound(SFX_OpenScreen, CutsceneUtils.DRH_MixerChannels.Effect, 0.7f);
		yield return new WaitForSeconds(0.75f);
		TypeText(Screen_SetupVessel_Texts[0], "Now, we can move onto your avatar.", 1f, PlayTypeSound: true);
		yield return new WaitForSeconds(3.5f);
		TypeText(Screen_SetupVessel_Texts[0], "Please customize the entity to your liking.", 1f, PlayTypeSound: true);
		HypoasterArmsAnimator.Play("NewBootUp_HypoasterArms_PrepareRightTyping");
		yield return new WaitForSeconds(2.5f);
		CutsceneUtils.PlaySound(SFX_Notification, CutsceneUtils.DRH_MixerChannels.Effect, 0.7f);
		Screen_SetupVessel_VesselMaker.SetActive(value: true);
		TypeText(Screen_SetupVessel_Texts[3], $"<color=yellow>{PlayerInput.Instance.Key_Up},<br>{PlayerInput.Instance.Key_Down},<br>{PlayerInput.Instance.Key_Left},<br>{PlayerInput.Instance.Key_Right}</color><br>to navigate.<br><br><color=yellow>{PlayerInput.Instance.Key_Confirm}</color><br>to finish.       ", 1f, PlayTypeSound: true);
		VesselIndex_Head = PlayerPrefs.GetInt("Game_VesselHead", 0);
		VesselIndex_Body = PlayerPrefs.GetInt("Game_VesselBody", 0);
		VesselIndex_Legs = PlayerPrefs.GetInt("Game_VesselLegs", 0);
		yield return null;
		int currentPartSelection = 0;
		int tempHeadIndex = VesselIndex_Head;
		int tempBodyIndex = VesselIndex_Body;
		int tempLegIndex = VesselIndex_Legs;
		bool canProgress = false;
		while (!canProgress)
		{
			VesselMaker_Head_ArrowLeft.sprite = Screen_SetupVessel_Sprite_ArrowDeselected;
			VesselMaker_Head_ArrowRight.sprite = Screen_SetupVessel_Sprite_ArrowDeselected;
			VesselMaker_Body_ArrowLeft.sprite = Screen_SetupVessel_Sprite_ArrowDeselected;
			VesselMaker_Body_ArrowRight.sprite = Screen_SetupVessel_Sprite_ArrowDeselected;
			VesselMaker_Legs_ArrowLeft.sprite = Screen_SetupVessel_Sprite_ArrowDeselected;
			VesselMaker_Legs_ArrowRight.sprite = Screen_SetupVessel_Sprite_ArrowDeselected;
			switch (currentPartSelection)
			{
			case 0:
				VesselMaker_Head_ArrowLeft.sprite = Screen_SetupVessel_Sprite_ArrowSelected;
				VesselMaker_Head_ArrowRight.sprite = Screen_SetupVessel_Sprite_ArrowSelected;
				break;
			case 1:
				VesselMaker_Body_ArrowLeft.sprite = Screen_SetupVessel_Sprite_ArrowSelected;
				VesselMaker_Body_ArrowRight.sprite = Screen_SetupVessel_Sprite_ArrowSelected;
				break;
			default:
				VesselMaker_Legs_ArrowLeft.sprite = Screen_SetupVessel_Sprite_ArrowSelected;
				VesselMaker_Legs_ArrowRight.sprite = Screen_SetupVessel_Sprite_ArrowSelected;
				break;
			}
			yield return null;
			if (Input.GetKeyDown(PlayerInput.Instance.Key_Up))
			{
				currentPartSelection = (currentPartSelection + 2) % 3;
				CutsceneUtils.PlaySound(SFX_Move, CutsceneUtils.DRH_MixerChannels.Effect, 0.7f);
				HypoasterArmsAnimator.Play("NewBootUp_HypoasterArms_RightType_Up", -1, 0f);
			}
			if (Input.GetKeyDown(PlayerInput.Instance.Key_Down))
			{
				currentPartSelection = (currentPartSelection + 1) % 3;
				CutsceneUtils.PlaySound(SFX_Move, CutsceneUtils.DRH_MixerChannels.Effect, 0.7f);
				HypoasterArmsAnimator.Play("NewBootUp_HypoasterArms_RightType_Down", -1, 0f);
			}
			if (Input.GetKeyDown(PlayerInput.Instance.Key_Left))
			{
				switch (currentPartSelection)
				{
				case 0:
					tempHeadIndex--;
					break;
				case 1:
					tempBodyIndex--;
					break;
				default:
					tempLegIndex--;
					break;
				}
				CutsceneUtils.PlaySound(SFX_Move, CutsceneUtils.DRH_MixerChannels.Effect, 0.7f);
				HypoasterArmsAnimator.Play("NewBootUp_HypoasterArms_RightType_Left", -1, 0f);
			}
			if (Input.GetKeyDown(PlayerInput.Instance.Key_Right))
			{
				switch (currentPartSelection)
				{
				case 0:
					tempHeadIndex++;
					break;
				case 1:
					tempBodyIndex++;
					break;
				default:
					tempLegIndex++;
					break;
				}
				CutsceneUtils.PlaySound(SFX_Move, CutsceneUtils.DRH_MixerChannels.Effect, 0.7f);
				HypoasterArmsAnimator.Play("NewBootUp_HypoasterArms_RightType_Right", -1, 0f);
			}
			if (Input.GetKeyDown(PlayerInput.Instance.Key_Confirm))
			{
				HypoasterArmsAnimator.Play("NewBootUp_HypoasterArms_RightType_Left", -1, 0f);
				VesselIndex_Head = tempHeadIndex;
				VesselIndex_Body = tempBodyIndex;
				VesselIndex_Legs = tempLegIndex;
				VesselMaker_Head_ArrowLeft.sprite = Screen_SetupVessel_Sprite_ArrowDeselected;
				VesselMaker_Head_ArrowRight.sprite = Screen_SetupVessel_Sprite_ArrowDeselected;
				VesselMaker_Body_ArrowLeft.sprite = Screen_SetupVessel_Sprite_ArrowDeselected;
				VesselMaker_Body_ArrowRight.sprite = Screen_SetupVessel_Sprite_ArrowDeselected;
				VesselMaker_Legs_ArrowLeft.sprite = Screen_SetupVessel_Sprite_ArrowDeselected;
				VesselMaker_Legs_ArrowRight.sprite = Screen_SetupVessel_Sprite_ArrowDeselected;
				PlayerPrefs.SetInt("Game_VesselHead", VesselIndex_Head);
				PlayerPrefs.SetInt("Game_VesselBody", VesselIndex_Body);
				PlayerPrefs.SetInt("Game_VesselLegs", VesselIndex_Legs);
				CutsceneUtils.PlaySound(SFX_Confirm, CutsceneUtils.DRH_MixerChannels.Effect, 0.7f);
				canProgress = true;
			}
			tempHeadIndex = (tempHeadIndex + Sprites_VesselHeads.Length) % Sprites_VesselHeads.Length;
			tempBodyIndex = (tempBodyIndex + Sprites_VesselBody.Length) % Sprites_VesselBody.Length;
			tempLegIndex = (tempLegIndex + Sprites_VesselLegs.Length) % Sprites_VesselLegs.Length;
			VesselMaker_Head.sprite = Sprites_VesselHeads[tempHeadIndex];
			VesselMaker_Body.sprite = Sprites_VesselBody[tempBodyIndex];
			VesselMaker_Legs.sprite = Sprites_VesselLegs[tempLegIndex];
		}
		Screen_SetupVessel_VesselMaker.SetActive(value: false);
		yield return new WaitForSeconds(1f);
		HypoasterArmsAnimator.Play("NewBootUp_HypoasterArms_StopRightTyping");
		HypoasterArmsAnimator.Play("NewBootUp_HypoasterArms_StopRightTyping", 1);
		TypeText(Screen_SetupVessel_Texts[0], "Name your avatar, a representation of YOU.", 1f, PlayTypeSound: true);
		yield return new WaitForSeconds(1f);
		HypoasterArmsAnimator.Play("NewBootUp_HypoasterArms_PrepareTyping");
		Screen_SetupVessel_Texts[1].text = PlayerPrefs.GetString("Game_PlayerName", "");
		yield return new WaitForSeconds(1.25f);
		CutsceneUtils.PlaySound(SFX_Notification, CutsceneUtils.DRH_MixerChannels.Effect, 0.7f);
		Screen_SetupVessel_Name.SetActive(value: true);
		List<string> ValidLetters = new List<string>
		{
			"A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
			"K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
			"U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d",
			"e", "f", "g", "h", "i", "j", "k", "l", "m", "n",
			"o", "p", "q", "r", "s", "t", "u", "v", "w", "x",
			"y", "z"
		};
		TMP_Text targetText = Screen_SetupVessel_Texts[1];
		bool typing = true;
		bool cursorVisible = true;
		float cursorBlinkRate = 0.5f;
		float nextBlinkTime = Time.time + cursorBlinkRate;
		while (typing)
		{
			HypoasterArmsAnimator.SetBool("HoldingBackspace", Input.GetKey(KeyCode.Backspace));
			if (Input.GetKeyDown(KeyCode.Backspace))
			{
				CutsceneUtils.PlaySound(SFX_TypingSound[Random.Range(0, SFX_TypingSound.Length)], CutsceneUtils.DRH_MixerChannels.Effect, Random.Range(0.65f, 0.85f), Random.Range(0.9f, 1.1f));
			}
			if (targetText.text.ToUpper() == "GASTER")
			{
				targetText.text = "";
				CutsceneUtils.PlaySound(SFX_Deny, CutsceneUtils.DRH_MixerChannels.Effect, Random.Range(0.65f, 0.85f), Random.Range(0.9f, 1.1f));
			}
			else
			{
				string inputString = Input.inputString;
				for (int i = 0; i < inputString.Length; i++)
				{
					char c = inputString[i];
					if (ValidLetters.Contains(c.ToString()))
					{
						if (targetText.text.Length < 12)
						{
							HypoasterArmsAnimator.Play($"NewBootUp_HypoasterArms_Type{Random.Range(1, 5)}", -1, 0f);
							CutsceneUtils.PlaySound(SFX_TypingSound[Random.Range(0, SFX_TypingSound.Length)], CutsceneUtils.DRH_MixerChannels.Effect, Random.Range(0.65f, 0.85f), Random.Range(0.9f, 1.1f));
							targetText.text += c;
						}
						continue;
					}
					switch (c)
					{
					case '\b':
						if (targetText.text.Length > 0)
						{
							targetText.text = targetText.text.Substring(0, targetText.text.Length - 1);
						}
						break;
					case '\n':
					case '\r':
						if (targetText.text.ToUpper() != "GASTER" && targetText.text.Length > 0)
						{
							HypoasterArmsAnimator.Play("NewBootUp_HypoasterArms_Type4", -1, 0f);
							CutsceneUtils.PlaySound(SFX_TypingSound[Random.Range(0, SFX_TypingSound.Length)], CutsceneUtils.DRH_MixerChannels.Effect, Random.Range(0.65f, 0.85f), Random.Range(0.9f, 1.1f));
							PlayerPrefs.SetString("Game_PlayerName", targetText.text);
							typing = false;
						}
						break;
					}
				}
			}
			if (Time.time >= nextBlinkTime)
			{
				cursorVisible = !cursorVisible;
				nextBlinkTime = Time.time + cursorBlinkRate;
			}
			if (targetText.text == "")
			{
				Screen_SetupVessel_Texts[2].text = (cursorVisible ? "|请输入名字..." : " 请输入名字...");
			}
			else
			{
				Screen_SetupVessel_Texts[2].text = (cursorVisible ? (targetText.text + "|") : (targetText.text ?? ""));
			}
			yield return null;
		}
		yield return new WaitForSeconds(0.25f);
		HypoasterArmsAnimator.Play("NewBootUp_HypoasterArms_StopTyping");
		yield return new WaitForSeconds(0.1f);
		Screen_SetupVessel_Name.SetActive(value: true);
		yield return new WaitForSeconds(0.25f);
		TypeText(Screen_SetupVessel_Texts[0], "", 1f, PlayTypeSound: false);
		yield return new WaitForSeconds(0.25f);
		Screen_SetupVessel.SetActive(value: false);
		yield return new WaitForSeconds(1f);
		if (PlayerPrefs.GetInt("Game_SingularVesselEditorMode", 0) == 1)
		{
			UI_FADE.Instance.StartFadeIn(2, 1f, UnpauseOnEnd: false, NewMainMenuManager.MainMenuStates.Console);
		}
		else
		{
			hasFinishedVesselCreation = true;
		}
	}

	public void TypeText(TextMeshProUGUI TargetText, string Text, float SpeedMultiplier, bool PlayTypeSound)
	{
		StartCoroutine(PlayText(TargetText, Text, SpeedMultiplier, PlayTypeSound));
	}

	private IEnumerator PlayText(TextMeshProUGUI TargetText, string Text, float SpeedMultiplier, bool PlayTypeSound)
	{
		string StoredText = (TargetText.text = Text);
		int Text_SubtractedRichText = 0;
		_ = StoredText;
		TargetText.maxVisibleCharacters = 0;
		int MaxVisibleCharacters = 0;
		bool ForcedFinishText = false;
		int messageCharLength = StoredText.Length;
		char[] messageCharacters = StoredText.ToCharArray();
		while (MaxVisibleCharacters < messageCharLength)
		{
			if (messageCharacters[MaxVisibleCharacters].ToString() == " ")
			{
				MaxVisibleCharacters++;
				yield return new WaitForSeconds(0.0265f * SpeedMultiplier);
			}
			else if (StoredText[MaxVisibleCharacters] == '<')
			{
				int num = MaxVisibleCharacters;
				int num2 = StoredText.IndexOf('>', num);
				if (num2 != -1)
				{
					int num3 = num2 - num + 1;
					MaxVisibleCharacters += num3;
					Text_SubtractedRichText += num3;
				}
			}
			else if (messageCharacters[MaxVisibleCharacters].ToString() == "(")
			{
				MaxVisibleCharacters++;
				yield return new WaitForSeconds(0.0265f * SpeedMultiplier);
			}
			else if (messageCharacters[MaxVisibleCharacters].ToString() == ")")
			{
				MaxVisibleCharacters++;
				yield return new WaitForSeconds(0.0265f * SpeedMultiplier);
			}
			else if (StoredText[MaxVisibleCharacters].ToString() == "@")
			{
				StoredText = (TargetText.text = StoredText.Remove(MaxVisibleCharacters, 1));
				_ = StoredText;
				messageCharacters = StoredText.ToCharArray();
				messageCharLength = StoredText.Length;
				yield return new WaitForSeconds(0.125f * SpeedMultiplier);
			}
			else if (StoredText[MaxVisibleCharacters].ToString() == "#")
			{
				StoredText = (TargetText.text = StoredText.Remove(MaxVisibleCharacters, 1));
				_ = StoredText;
				messageCharacters = StoredText.ToCharArray();
				messageCharLength = StoredText.Length;
				yield return new WaitForSeconds(0.5f * SpeedMultiplier);
			}
			else if (StoredText[MaxVisibleCharacters].ToString() == ";")
			{
				yield return new WaitForSeconds(0.2f * SpeedMultiplier);
				StoredText = RemoveSelectedCharacter(StoredText, MaxVisibleCharacters);
				StoredText = (TargetText.text = AddSelectedCharacter(StoredText, MaxVisibleCharacters, "\n"));
				_ = StoredText;
				messageCharLength = StoredText.Length;
				MaxVisibleCharacters++;
			}
			else if (StoredText[MaxVisibleCharacters] == '|')
			{
				int startIndex = MaxVisibleCharacters + 1;
				int endIndex;
				for (endIndex = startIndex; endIndex < StoredText.Length && char.IsDigit(StoredText[endIndex]); endIndex++)
				{
					yield return null;
				}
				if (int.TryParse(StoredText.Substring(startIndex, endIndex - startIndex), out var result) && result >= 0 && result < StoredAdditiveValues.Count)
				{
					string value = StoredAdditiveValues[result];
					StoredText = StoredText.Remove(MaxVisibleCharacters, endIndex - MaxVisibleCharacters);
					StoredText = (TargetText.text = StoredText.Insert(MaxVisibleCharacters, value));
					_ = StoredText;
					messageCharLength = StoredText.Length;
					messageCharacters = StoredText.ToCharArray();
					MaxVisibleCharacters++;
					yield return new WaitForSeconds(0.0265f * SpeedMultiplier);
				}
				else
				{
					Debug.LogError("Invalid index after '|' or index out of range.");
					MaxVisibleCharacters++;
					yield return new WaitForSeconds(0.0265f * SpeedMultiplier);
				}
			}
			else if (StoredText[MaxVisibleCharacters].ToString() == "~")
			{
				yield return new WaitForSeconds(0.2f * SpeedMultiplier);
				StoredText = RemoveSelectedCharacter(StoredText, MaxVisibleCharacters);
				StoredText = (TargetText.text = AddSelectedCharacter(StoredText, MaxVisibleCharacters, "\n"));
				_ = StoredText;
				messageCharLength = StoredText.Length;
				MaxVisibleCharacters++;
			}
			else if (StoredText[MaxVisibleCharacters].ToString() == ",")
			{
				MaxVisibleCharacters++;
				TargetText.maxVisibleCharacters = MaxVisibleCharacters - Text_SubtractedRichText;
				yield return new WaitForSeconds(0.165f * SpeedMultiplier);
			}
			else if (StoredText[MaxVisibleCharacters].ToString() == ".")
			{
				MaxVisibleCharacters++;
				yield return new WaitForSeconds(0.0265f * SpeedMultiplier);
			}
			else if (!ForcedFinishText)
			{
				MaxVisibleCharacters++;
				if (PlayTypeSound)
				{
					CutsceneUtils.PlaySound(TypeSound, CutsceneUtils.DRH_MixerChannels.Dialogue, 0.5f);
				}
				yield return new WaitForSeconds(0.0265f * SpeedMultiplier);
			}
			else
			{
				MaxVisibleCharacters++;
			}
			TargetText.maxVisibleCharacters = MaxVisibleCharacters - Text_SubtractedRichText;
		}
	}

	private string RemoveSelectedCharacter(string text, int Index)
	{
		return text.Remove(Index, 1);
	}

	private string AddSelectedCharacter(string text, int Index, string Insert)
	{
		return text.Insert(Index, Insert);
	}

	public int CountOfStringInText(string TargetText, char Counter)
	{
		int num = 0;
		bool flag = false;
		char[] array = TargetText.ToCharArray();
		for (int i = 0; i < array.Length; i++)
		{
			if (array[i] == Counter)
			{
				flag = true;
			}
			else if (false)
			{
				num++;
			}
		}
		return num;
	}

	public static string RemoveRichTextTags(string input)
	{
		string pattern = "<.*?>";
		return Regex.Replace(input, pattern, "");
	}
}
